/*  ----------------------------------------------------------------------------
 *  Arello Mobile
 *  Fast 3d Engine
 *  ----------------------------------------------------------------------------
 * Except where otherwise noted, this work is licensed under
 * http://creativecommons.org/licenses/by/3.0
 */

#include "EnvelopeBuilder.h"

Envelope EnvelopeBuilder::get_result()
{
	if(current.is_sustain_active() && current.sustain_point >= current.envelope_points.size())
		current.sustain_point = current.envelope_points.size() - 1;
	
	return current;
}

void EnvelopeBuilder::make_envelope_type( unsigned char type )
{
	if ( type & 1 )
	{
		current.active = true;
		if ( type & 2 )
			current.sustain_active = true;
		if ( type & 4 )
			current.loop_active = true;
	}
}

void EnvelopeBuilder::make_loop_end( int point )
{
	current.loop_end = point;
}

void EnvelopeBuilder::make_loop_begin( int point )
{
	current.loop_begin = point;
}

void EnvelopeBuilder::make_sustain_point( int point )
{
	current.sustain_point = point;
}

void EnvelopeBuilder::make_points( const EnvelopePoints & points )
{
	current.envelope_points = points;
}

EnvelopeBuilder::EnvelopeBuilder()
{}

